package com.office.doctorsoffice.services;


import javax.persistence.EntityManager;
import com.office.doctorsoffice.domain.Patient;

public class PatientService {
	protected EntityManager em;
	
	public PatientService (EntityManager em) {
		this.em = em;
		
	}	
	public PatientService() {}
	public Patient createPatient(int PatientID,String FirstName, String LastName, 
			String Address, String City, int ZipCode, String Phone, String Email) {
		Patient pat = new Patient();
		pat.setFirstName(FirstName);
		pat.setLastName(LastName);
		pat.setAddress(Address);
		pat.setCity(City);
		pat.setZipCode(ZipCode);
		pat.setPhone(Phone);
		pat.setEmail(Email);
		em.persist(pat);
		return pat;
		
	}
	
	public Patient findPatient(int PatientID) {
		return em.find(Patient.class,PatientID);
	}

	public void removePatient(int PatientID) {
		Patient pat = findPatient(PatientID);
		if (pat != null) {
		em.remove(pat);	   
		}
    }
}


